home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / DATABASE / FRANK / !Frank / RunImage (.txt) < prev   
RISC OS BBC BASIC V Source  |  1995-09-05  |  45KB  |  1,902 lines

  1.  This program is (C)1995 Mike Goatly.
  2.  Feel free to use this source code, but please, if you use any parts
  3.  that are 'Frank specific' i.e. the sentence constuction procedures, etc.
  4.  please give me credit for my hard word.
  5.  "Wimp_CloseDown":
  6. $;" at ";
  7.  "Wimp_Initialise",200,&4B534154,"Frank" 
  8.  Ver%,Task
  9.  Ver%>=350 
  10.  DragASprite=
  11.  DragASprite=
  12.  Block &1200,Template% &1800
  13. Icon=
  14. IconOnBar("!Frank")
  15. LoadTemplates
  16. Error
  17. DefineMenus
  18. SetUp
  19. Error
  20. Quit=
  21.  Quit
  22. Poll(
  23. Poll(0))
  24.  Decoding% 
  25. Decode
  26.  Respond% 
  27. Respond
  28.  "Wimp_CloseDown"
  29.  Polling
  30. Poll(mask%)
  31.     Block!0=mask%
  32. !#    
  33.  "Wimp_Poll",0,Block 
  34. Poll(Reason%)
  35.  Reason% 
  36. &(        
  37.  1 : 
  38. RedrawWindow(Block!0)
  39. '(        
  40.  2 : 
  41. OpenWindow(Block!0,
  42. ('        
  43.  3 : 
  44. CloseWindow(Block!0)
  45. )%        
  46.  6 : 
  47. ButtonClick(Block)
  48.         
  49.  7 : 
  50. DragDrop
  51.         
  52.  8 : 
  53. ProcessKey
  54. ,$        
  55.  9 : 
  56. MenuSelect(Block)
  57. -%        
  58.  17,18 : 
  59. Message(Block)
  60. .        
  61. DragDrop
  62.  Window%,Icon%
  63. 3$    
  64. Istate(Save%,2):n%=Block!28
  65. 4'    
  66.  "Wimp_GetPointerInfo",,Block
  67. 5'    Window%=Block!12:Icon%=Block!16
  68. 6;    Block!20=64:Block!32=0:Block!36=1:Block!40=Block!12
  69. 7:    Block!44=Block!16:Block!48=!Block:Block!52=Block!4
  70.     Block!56=10240
  71. 98    Block!60=&1A1:$(Block+64)=
  72. Leaf(
  73. ZeroString(n%))
  74. :;    
  75.  "Wimp_SendMessage",17,Block+20,Block!12,Block!16
  76. Istate(Block!0,Block!4)
  77. >%    
  78.  "Wimp_GetIconState",,Block
  79. ZeroString(Addr%)
  80. C"    
  81.  ?Addr%>31 
  82.  ?Addr%<>127
  83. D"        t$+=
  84. (?Addr%):Addr%+=1
  85. E        
  86. Leaf(a$)
  87. JL    
  88. (a$="No input file" 
  89.  a$="<Wimp$Scrap>" 
  90.  a$="<Printer$Scrap>") 
  91.         p%=
  92. L+        
  93. a$,p%,1)=" " 
  94.  p%>0:p%-=1:
  95.         a$=
  96. a$,p%)
  97. N,        
  98. a$,p%,1)<>"." 
  99.  p%>0:p%-=1:
  100.         Res$=
  101. a$,p%+1),10)
  102. P        
  103.         Res$=a$
  104. R        
  105. S    =Res$
  106. GetLeaf(Name$)
  107. Name$,".")
  108. W'        Name$=
  109. Name$,
  110. Name$,".")+1)
  111. X        
  112. =Name$+
  113. GetFilename(ptr)
  114.     f$=""
  115.  ?ptr<>0 
  116.  ?ptr<>13
  117. ^           f$=f$+
  118. ?ptr:ptr+=1
  119. _        
  120. Message(Handle%)
  121. cE    
  122.  Handle%!4<>Task 
  123.  ((Handle%!16=5) 
  124.  (Handle%!40<>&1A1)) 
  125.         
  126.  Handle%!16 
  127.              
  128.  0:Quit=
  129.              
  130. g'             
  131.  3,5:
  132.  Handle%!12=0 
  133. hO                        
  134.  Handle%!20=Prefs% 
  135.  Handle%!24=6 
  136.  Handle%!24=5 
  137. iT                            
  138.  Handle%!40=&1A1 
  139.  AutoLoad$=
  140. GetFilename(Block+44)
  141. j,                            
  142. UpdatePrefs
  143.                         
  144. l>                            Source$=
  145. GetFilename(Block+44)
  146. m4                            CurrentFile$=Source$
  147. n@                            HisRef%=Block!8:SrcTask%=Block!4
  148. oE                            Buf%=Block:Buf%!36=-1:Buf%!12=HisRef%
  149. pD                            Buf%!16=4:$(Buf%+44)=CurrentFile$+
  150. q@                            !Buf%=(48+
  151. (CurrentFile$)) 
  152. rF                            
  153.  "Wimp_SendMessage",17,Buf%,SrcTask%
  154. s2                            
  155. LoadFile(Handle%)
  156.                         
  157.                      
  158. v>            
  159.  &502:Buf%=Block:Buf%!12=Block!8:Buf%!16=&503
  160. wD                        Help=Buf%+20:Handle=Buf%!32:Icon=Buf%!36
  161. x!                        
  162. y<                        ?Help=0:!Buf%=(Help+4-Buf%)
  163. z@                        
  164.  "Wimp_SendMessage",17,Buf%,Buf%!4
  165.         
  166. |        
  167.  Handle 
  168. .        
  169. Hlp("This is Frank's icon.")
  170. V                
  171. Hlp("Clicking SELECT/ADJUST on it will open up the main window.")
  172.         
  173.  Main%:
  174.  Icon 
  175. ?                    
  176. Hlp("Hey!  It's Frank's window!")
  177. @                    
  178. Hlp("This is the vocabulary icon.")
  179.                             
  180. Hlp("Clicking SELECT/ADJUST on this will open the vocabulary window.  In this you will be able to see what words are currently known, and perform operations on them.")
  181. @                    
  182. Hlp("This is the quick save icon.")
  183. _                            
  184. Hlp("Clicking SELECT/ADJUST on it will open the save window.")
  185. A                    
  186. Hlp("This is the preferences icon.")
  187. j                            
  188. Hlp("Clicking SELECT/ADJUST on it will open Frank's preferences window.")
  189. F                    
  190. Hlp("This is where you enter your text.")
  191.                             
  192. Hlp("If the caret is not in the box, then click the SELECT button in it, and the caret will appear.")
  193.                    
  194.         
  195.  Output%:
  196. Hlp("This is where Frank responds to you.  Your comments appear in red, Franks appear in blue.  Only the last ten sentences are stored, and you can view them using the scroll bar.  New comments always appear on the bottom line.")
  197.         
  198.  Info%:
  199.  Icon% 
  200. N                    
  201. Hlp("Ohhh.... lots of interesting information!")
  202. f                    
  203. Hlp("A 256 colour sprite...  sorry to all you users of older computers!")
  204. >                    
  205. Hlp("Another 256 colour sprite!")
  206.                     
  207.  1,2:
  208. Hlp("The original version of Frank (written on a 286 PC in QBasic) wasn't very good... turn off word linkage and word frequency from preferences, and you'll see how it used to respond!")
  209. 0                    
  210.  3,4:
  211. Hlp("That's me!")
  212. Q                    
  213.  5,6:
  214. Hlp("The first version ever was written in 1993.")
  215. J                    
  216.  7,8:
  217. Hlp("Spread the disc as well as the word!")
  218. 5                    
  219. Hlp("True, very true.")
  220.                    
  221.         
  222.  Prefs%:
  223.  Icon 
  224. H                    
  225. Hlp("This is Frank's Preferences window.")
  226. Y                    
  227. Hlp("This is the current maximum number of words allowed.")
  228. b                    
  229. Hlp("This is the current maximum number of links per word allowed.")
  230.                     
  231. Hlp("Clicking on this will turn learning on.  This means that new words will be added to the vocabulary.")
  232.                     
  233. Hlp("Clicking on this will turn learning off.  This will protect the current vocabulary from being changed when new words are added.")
  234.                     
  235. Hlp("Clicking on this means that commas will be taken as the end to a sentence.  Words separated by a comma will not have a link added between them.")
  236.                     
  237. Hlp("Clicking on this means that commas will be ignored, and links will be created between words separated with a comma.")
  238.                     
  239. Hlp("This box contains characters that will be ignored by Frank.  For example, if the symbol '^' was included, the word 'Hel^lo' would be interpreted as 'hello'.")
  240.                     
  241. Hlp("Clicking on this will turn word linkage on.  When Frank constructs sentences, he will take into account what words can follow one another.")
  242.                     
  243. Hlp("Clicking on this will turn word linkage off.  When responding, Frank will select upto six random words as a sentence.  This makes very little sense what so ever.")
  244.                     
  245. Hlp("Clicking on this will turn 'word frequency' on.  This means that when Frank constructs a sentence, he will take into account how many times words have been linked together.")
  246. U                    
  247. Hlp("Clicking on this will turn 'word frequency' off.")
  248. s                    
  249. Hlp("Clicking on this makes Frank save the current preferences with the vocabulary.")
  250. u                    
  251. Hlp("Clicking on this prevents Frank from saving the preferences with the vocabulary.")
  252.                     
  253.  5,6:
  254. Hlp("Dragging a vocabulary file onto here selects the vocabulary to be loaded when Frank is initially run.")
  255. n                    
  256. Hlp("Clicking on here restores the preferences that were selected upon startup.")
  257.                     
  258. Hlp("Clicking on this saves the preferences to disc.  They will automatically be loaded when Frank is run.")
  259.                    
  260.          
  261.  Message%:
  262.  Icon 
  263. G                        
  264.  -1,0:
  265. Hlp("Frank has a message for you!")
  266. L                        
  267. Hlp("Click on here to accept the message.")
  268.                       
  269.         
  270.  Vocab%:
  271.  Icon 
  272. G                        
  273. Hlp("This is the correct word icon.")
  274. }                                
  275. Hlp("By clicking on this, then on one of the words, you can correct spelling mistakes.")
  276. F                        
  277. Hlp("This is the delete word icon.")
  278. s                                
  279. Hlp("By clicking on this, you can delete unwanted words by clicking on them.")
  280. G                        
  281. Hlp("This is the 'show links' icon.")
  282.                                 
  283. Hlp("By clicking on this, then on a word, you can view what other words the given word can be followed by.  (in the current vocabulary)")
  284. I                        
  285. Hlp("This is the case selecting icon.")
  286.                                 
  287. Hlp("By clicking on this icon, then on a word, you toggle the case of the given words first letter.  This is useful for names, dates etc.")
  288. t                        
  289. Hlp("Clicking SELECT on this arrow will scroll the vocabulary list up one place.")
  290. v                                
  291. Hlp("Clicking ADJUST on this arrow will scroll the vocabulary list up one page.")
  292. v                        
  293. Hlp("Clicking SELECT on this arrow will scroll the vocabulary list down one place.")
  294. x                                
  295. Hlp("Clicking ADJUST on this arrow will scroll the vocabulary list down one page.")
  296. D                        
  297. Hlp("This is the vocabulary window.")
  298.                                     
  299. Hlp("The words are shown in the boxes down the middle of the window, and on their left is their word number.")
  300.                         
  301. B        
  302.  Correct%:
  303. Hlp("This is the word correction window.")
  304.                         
  305. Hlp("The word in it's original form is diaplayed in the top box.  Enter the corrected version in the box below it, and click on correct.")
  306.         
  307.  Links%:
  308.  Icon 
  309. n                        
  310. Hlp("Clicking SELECT on this arrow will scroll the link list up one place.")
  311. p                                
  312. Hlp("Clicking ADJUST on this arrow will scroll the link list up one page.")
  313. p                        
  314. Hlp("Clicking SELECT on this arrow will scroll the link list down one place.")
  315. r                                
  316. Hlp("Clicking ADJUST on this arrow will scroll the link list down one page.")
  317. C                        
  318. Hlp("This is the add link icon.")
  319. v                                
  320. Hlp("Clicking SELECT/ADJUST on this icon will open up the link creation window.")
  321. E                        
  322. Hlp("This is the break link icon.")
  323.                                 
  324. Hlp("Clicking on this icon, then on one of the linked words (from this window) will remove the selected word from the link list.  If this leaves no resultant links, the word will automatically end a sentence.")
  325. G                        
  326. Hlp("This is the 'show links' icon.")
  327.                                 
  328. Hlp("By clicking on this, then on a word, you can view what other words the given word can be followed by.  (in the current vocabulary)")
  329. H                        
  330. Hlp("This is the reset counter icon.")
  331.                                 
  332. Hlp("Clicking on this icon, then on one of the linked words, will reset the number of times that word has been called to 1.")
  333. C                        
  334. Hlp("This is the link list window.")
  335. e                                    
  336. Hlp("It shows all the words that a given word can link to.")
  337.                     
  338.          
  339.  AddLink%:
  340.  Icon 
  341. u                        
  342. Hlp("Clicking on this icon will allow you to link a word to the end of a sentence.")
  343.                         
  344. Hlp("This is the add link window.  By clicking on a word from the vocabulary window, and the clicking on the Add icon, located in the bottom right of this window, you can create links between words.")
  345.                       
  346.         
  347. Hlp(Txt$)
  348.     $Help=Txt$+"|M"
  349.     Help+=
  350. (Txt$)+2
  351.  Keyboard control
  352. ProcessKey
  353.  Win%,Key%,Caught%
  354.     Win%=Block!0
  355.     Key%=Block!24
  356.     Caught%=
  357.  Win% 
  358. .        
  359.  Correct%:
  360.  Key%=13 
  361. ChangeWord
  362. ,        
  363.  Main%:
  364.  Key%=13 
  365.  Waiting%=
  366. &                    
  367. MoveSentences
  368. @                    LastSentence$(1)=$
  369. ReadIconText(Main%,0)
  370. /                    
  371. ReInitIcon(Main%,0,"")
  372. D                    
  373.  "Wimp_SetCaretPosition",Main%,0,0,0,-1,-1
  374. $                    LastWho(1)=1
  375. '                    
  376. UpdateLastSent
  377. $                    
  378.  Learning 
  379. =                        Decoding%=
  380. :Respond%=
  381. :Waiting%=
  382. '                        DecodePos=1
  383.                     
  384. =                        Decoding%=
  385. :Respond%=
  386. :Waiting%=
  387.                     
  388.                    
  389.          
  390.  Prefs%:
  391.  Key%=13 
  392. >                        AutoLoad$=$
  393. ReadIconText(Prefs%,5)
  394. =                        Ignore$=$
  395. ReadIconText(Prefs%,37)
  396.                     
  397. 9        
  398.  Message%:
  399.  Key%=13 
  400. CloseWindow(Message%)
  401. *        
  402.  Save%:
  403.  Key%=13 
  404. QuickSave
  405. '        
  406.  "Wimp_ProcessKey",Key%
  407.         
  408. /    
  409.  Caught%=
  410.  "Wimp_ProcessKey",Key%
  411. MoveSentences
  412.  shift=10 
  413. :        
  414.  LastSentence$(shift),LastSentence$(shift-1)
  415. .        
  416.  LastWho(shift),LastWho(shift-1)
  417.  shift
  418.  Initialisation
  419. SetUp
  420. C    CurrentFile$="FrankVocab":
  421. ReInitIcon(Save%,0,CurrentFile$)
  422.     Version=300
  423. ?    VocabState=0:VocabOffSet=0:LinkState=0:ShowingLinksOf=0
  424.     TopWords=15000
  425.     TopLinks=5000
  426.     Warned=
  427. '    CurrentTopWords=0:LearningOff=
  428. .    Welcome$="Hi!  I'm Frank, talk to me!"
  429. DefaultPrefs
  430. 7    
  431.  LastSentence$(10),Word$(MaxWords),LastWho(10)
  432. &    Word$(0)="<Start of sentence>"
  433. .    LastSentence$(1)=Welcome$:LastWho(1)=2
  434. UpdateLastSent
  435. 0    
  436. +(MaxWords*MaxLinks*10)+(MaxWords*40)
  437. /    
  438.  Links (MaxWords+2)*((MaxLinks*2)+2)*4
  439.     Links!0=0:Links!4=0
  440.  WordData MaxWords+1
  441.     Waiting%=
  442.     Decoding%=
  443.     Respond%=
  444.  AutoLoad$<>"" 
  445.         F=
  446. (AutoLoad$)
  447.         
  448.         
  449.  F=0 
  450.  :            AutoLoad$="":
  451. SavePreferences:
  452. UpdatePrefs
  453.         
  454. "&            CurrentFile$=AutoLoad$
  455.             
  456. $6            LastSentence$(1)=Welcome$:LastWho(2)=2
  457. %Q            LastSentence$(2)="Autoloaded vocabulary: "+
  458. GetLeaf(CurrentFile$)
  459.             
  460. UpdateLastSent
  461.         
  462. (        
  463.  "OS_GetEnv" 
  464.  $Block
  465. $Block,"-load") 
  466. +F       CurrentFile$=
  467. $Block,
  468. ($Block)-(
  469. $Block,"-load")+5))       
  470.        
  471. Load       
  472. ResetVocab
  473. 1C    CurrentFile$="FrankVocab":
  474. ReInitIcon(Save%,0,CurrentFile$)
  475. 2/    VocabOffSet=0:ShowingLinksOf=0:Warned=
  476. 3     LearningOff=
  477. :Learning=
  478. UpdatePrefs
  479.  Reset=0 
  480. 6#        LastSentence$(Reset)=""
  481.         LastWho(Reset)=0
  482.  Reset
  483. 9.    LastSentence$(1)=Welcome$:LastWho(1)=2
  484. UpdateLastSent
  485.     Links!0=0:Links!4=0
  486.  Reset=0 
  487.  MaxWords
  488.         WordData?Reset=0
  489. >#        Ptr=
  490. BasePointer(Reset)
  491. ?&        
  492.  Reset<=CurrentTopWords 
  493. @%            
  494.  Clear=0 
  495.  Links!Ptr
  496.                 Links!Ptr=0
  497. B#                Links!(Ptr+4)=0
  498.                 Ptr+=8
  499.             
  500.  Clear
  501.         
  502.         Word$(Reset)=""
  503.  Reset
  504.     CurrentTopWords=0
  505.     Waiting%=
  506.     Decoding%=
  507.     Respond%=
  508. UpdateVocab
  509. DefaultPrefs
  510. P     MaxWords=300:MaxLinks=80
  511. Q+    Learning=
  512. :IgnoreCommas=
  513. :Linkage=
  514.     Frequency=
  515. :SavePrefs=
  516.     AutoLoad$=""
  517.     Ignore$="()*$&"
  518. LoadPreferences
  519. UpdatePrefs
  520. LoadPreferences
  521. Z#    Pref=
  522. ("<Frank$Dir>.Prefs")
  523.  Pref<>0 
  524. \M        
  525.  #Pref,MaxWords,MaxLinks,Learning,IgnoreCommas,Linkage,Frequency
  526. ]/        
  527.  #Pref,SavePrefs,AutoLoad$,Ignore$
  528. ^        
  529.  #Pref
  530. SavePreferences
  531. c#    Pref=
  532. ("<Frank$Dir>.Prefs")
  533. dI    
  534.  #Pref,MaxWords,MaxLinks,Learning,IgnoreCommas,Linkage,Frequency
  535. e+    
  536.  #Pref,SavePrefs,AutoLoad$,Ignore$
  537.  #Pref    
  538. IconOnBar(Spr$)
  539. jV    !Block=-1 : Block!4=0 : Block!8=0 : Block!12=68 : Block!16=68 : Block!20=&3102
  540.     Data$=Spr$
  541. l2    
  542.  Block!24 (
  543.  Data$+1) : $(Block!24)=Data$
  544. m'    Block!28=1 : Block!32=
  545.  Data$+1
  546. n*    
  547.  "Wimp_CreateIcon",,Block 
  548.  Icon
  549. o    =Icon
  550.  Icon control
  551. ReadIconText(Handle%,Icon%)
  552.     Block!0=Handle%
  553.     Block!4=Icon%
  554. u%    
  555.  "Wimp_GetIconState",,Block
  556. =Block!28
  557. createIcon(Handle%,ix0%,iy0%,ix1%,iy1%,flags%,Data$)
  558. y5    Block!0=Handle% : Block!4=ix0% : Block!8=iy0%
  559. z7    Block!12=ix1% : Block!16=iy1% : Block!20=flags%
  560.     $(Block+24)=Data$
  561. |+    
  562.  "Wimp_CreateIcon",,Block 
  563.  Icon%
  564. =Icon%
  565. deleteIcon(Handle%,Icon%)
  566. '    Block!0=Handle% : Block!4=Icon%
  567. #    
  568.  "Wimp_DeleteIcon",,Block
  569. getIconInfo(Handle%,Icon%)
  570. '    Block!0=Handle% : Block!4=Icon%
  571. %    
  572.  "Wimp_GetIconState",,Block
  573. D    ix0%=Block!8 : iy0%=Block!12 : ix1%=Block!16 : iy1%=Block!20
  574.     flags%=Block!24
  575.     Data$=$(Block+28)
  576. RedrawIcon(Handle%,Icon%,Spr$)
  577. @    
  578. getIconInfo(Handle%,Icon%) : 
  579. deleteIcon(Handle%,Icon%)
  580. ?    i%=
  581. createIcon(Handle%,ix0%,iy0%,ix1%,iy1%,flags%,Spr$)
  582. 9    
  583.  "Wimp_ForceRedraw",Handle%,ix0%,iy0%,ix1%,iy1%
  584. ReInitIcon(Handle%,Icon%,Text$)
  585. #    
  586. getIconInfo(Handle%,Icon%)
  587.     $Block!28=Text$
  588. #    
  589. setIcon(Handle%,Icon%,0,0)
  590. setIcon(Handle%,Icon%,Eor%,Mask%)
  591. &    !Block=Handle% : Block!4=Icon%
  592. '    Block!8=Eor%   : Block!12=Mask%
  593. %    
  594.  "Wimp_SetIconState",,Block
  595. SetaORb(Var,Icona,Iconb)
  596.      
  597.  Var 
  598.  Icona,Iconb
  599. ,    
  600. setIcon(Prefs%,Icona,Set%,SetBits%)
  601. .    
  602. setIcon(Prefs%,Iconb,Unset%,SetBits%)
  603.  Window control
  604. UpdateLastSent
  605.  Update=1 
  606. *        
  607. getIconInfo(Output%,Update-1)
  608. +        $Block!28=LastSentence$(Update)
  609. C        
  610.  LastWho(Update)=2 
  611.  Mask%=134217728 
  612.  Mask%=184549376
  613. 6        
  614. setIcon(Output%,Update-1,Mask%,251658240)
  615.  Update
  616. UpdatePrefs
  617. *    
  618. ReInitIcon(Prefs%,30,
  619. (MaxWords))
  620. *    
  621. ReInitIcon(Prefs%,34,
  622. (MaxLinks))
  623. '    
  624. ReInitIcon(Prefs%,5,AutoLoad$)
  625. &    
  626. ReInitIcon(Prefs%,37,Ignore$)
  627.     Set%=388083987
  628.     Unset%=385986835
  629.     SetBits%=387985683
  630.      
  631. SetaORb(Learning,18,19)
  632. $    
  633. SetaORb(IgnoreCommas,21,20)
  634. SetaORb(Linkage,10,11)
  635. !    
  636. SetaORb(Frequency,13,14)
  637. !    
  638. SetaORb(SavePrefs,25,26)
  639. UserMessage(Text$)
  640. %    
  641. ReInitIcon(Message%,0,Text$)
  642. OpenWindow(Message%,
  643. RedrawWindow(Handle)
  644.  More : Block!0=Handle
  645. -    
  646.  "Wimp_RedrawWindow",0,Block 
  647.  More
  648.     x1=Block!4 : y1=Block!8
  649.  More
  650. 2          
  651.  "Wimp_GetRectangle",,Block 
  652.  More
  653.         
  654. OpenWindow(Handle,Full)
  655.     Block!0=Handle
  656.  Full 
  657. :        
  658.  "Wimp_GetWindowState",0,Block : Block!28=-1
  659.         
  660. -        
  661.  Handle=Main% 
  662.  Block!28=Output%
  663.         
  664. $    
  665.  "Wimp_OpenWindow",0,Block
  666. *    
  667.  Handle=Main% 
  668. OpenOutputWindow
  669.         
  670. OpenOutputWindow
  671. A    AddX=OffSetX+Block!4:AddY=OffSetY+Block!8:OldPos=Block!28
  672.     Block!0=Output%
  673. (    
  674.  "Wimp_GetWindowState",0,Block
  675. 6    Width=Block!12-Block!4:Height=Block!16-Block!8
  676. J    Block!4=AddX:Block!8=AddY:Block!12=AddX+Width:Block!16=AddY+Height
  677.     Block!28=-1
  678. (    
  679.  "Wimp_OpenWindow",0,Block    
  680. CloseWindow(Handle)
  681.     Block!0=Handle
  682. %    
  683.  "Wimp_CloseWindow",0,Block
  684.  Handle=Main% 
  685.         Block!0=Output%
  686. )        
  687.  "Wimp_CloseWindow",0,Block
  688.         
  689.  Template stuff
  690. LoadTemplates
  691. A    
  692.  "Wimp_OpenTemplate",,"<Frank$Dir>.Resources.Templates"
  693. !    Output%=
  694. Window("Output")
  695.     Main%=
  696. Window("Main")
  697.     Info%=
  698. Window("Info")
  699. #    Message%=
  700. Window("Message")
  701.     Prefs%=
  702. Window("Prefs")
  703.     Vocab%=
  704. Window("Vocab")
  705.     Save%=
  706. Window("Save")
  707. #    Correct%=
  708. Window("Correct")
  709.     Links%=
  710. Window("Links")
  711. #    AddLink%=
  712. Window("Addlink")
  713.  "Wimp_CloseTemplate"
  714.     Block!0=Main%
  715. '    
  716.  "Wimp_GetWindowState",,Block
  717.     LoX=Block!4:LoY=Block!8
  718.     Block!0=Output%
  719. '    
  720.  "Wimp_GetWindowState",,Block
  721.     HiX=Block!4:HiY=Block!8
  722. '    OffSetX=HiX-LoX:OffSetY=HiY-LoY
  723. Window(a$)
  724. #    
  725.  end%:end%=Template%+&1200
  726. J    
  727.  "Wimp_LoadTemplate",,Block,Template%,end%,-1,a$,0 
  728.  ,,Template%
  729. *    
  730.  "Wimp_CreateWindow",,Block 
  731. UpdateVocab
  732.  Draw=0 
  733. 8        
  734. ReInitIcon(Vocab%,Draw,
  735. (Draw+VocabOffSet))
  736. 1        
  737.  Draw+VocabOffSet<=CurrentTopWords 
  738. &            
  739.  VocabOffSet+Draw=0 
  740. E                
  741. ReInitIcon(Vocab%,Draw+10,"<Start of sentence>")
  742.             
  743. .                W$=Word$(Draw+VocabOffSet)
  744. 5                
  745.  WordData?(Draw+VocabOffSet)=1 
  746. 1                    
  747. W$,1)=
  748. UpperCase(
  749. W$,1))
  750.                 
  751. 2                
  752. ReInitIcon(Vocab%,Draw+10,W$)
  753.             
  754.         
  755. .            
  756. ReInitIcon(Vocab%,Draw+10,"")
  757.         
  758.  Draw
  759.  Menu stuff
  760. MenuSelect(Block)
  761.  Block!0 
  762. "$        
  763. OpenWindow(Info%,
  764. #%        
  765. OpenWindow(Prefs%,
  766.         
  767. QuickSave
  768.         
  769.  3:Quit=
  770. &        
  771. OpenMenu(menu%)
  772.  mx%,my%,mz%
  773.  mx%,my%,mz%
  774.  Handle%=-2 
  775.  my%=288
  776.  menu%>=0 
  777. .5        
  778.  "Wimp_CreateMenu",,menu%,mx%-64,my%+32
  779. /        
  780. CloseMenu
  781.  "Wimp_CreateMenu",-1
  782. 4%    
  783.  "Wimp_CloseWindow",0,Block
  784. DefineMenus
  785.  MenuFree &4000
  786.     Ptr=MenuFree
  787. ;.    
  788.  Menu$ : Menu%=
  789. CreateMenu(Menu$)
  790. <=    
  791.  "#Frank  ,Info#>Info%,Prefs#,Save Vocab>Save%,Quit"
  792. Par(Text$,Termin$)
  793. @3    End=Pos+1 : Pos=
  794. Text$+Termin$,Termin$,End)
  795. Text$,End,Pos-End)
  796. CreateMenu(Menu$)
  797.     Ptr=MenuFree
  798.     Pos=0
  799. Menu$,1)="#" 
  800. F)       Pos=1 : Title$=
  801. Par(Menu$,",")
  802. G        
  803.        Title$=""
  804. I        
  805.     $Ptr=Title$
  806. K1    Ptr?12=7 : Ptr?13=2 : Ptr?14=7 : Ptr?15=0
  807. L,    Ptr!16=196-24 : Ptr!20=44 : Ptr!24=0
  808. M!    Ptr+=28 : maxx%=
  809. (Title$)
  810. N        
  811. O6          item$=
  812. Par(Menu$,",") : 
  813. MenuItem(item$)
  814.  item$=""
  815. Q)    m%=MenuFree : m%!16=(maxx%*8+6)*2
  816.     MenuFree=Ptr
  817. MenuItem(Text$)
  818.  Text$="" 
  819. V#        Ptr!-24=(Ptr!-24) 
  820. W        
  821.         
  822.  Pos,Flag
  823. Y&        Flag=&00 : Pos=
  824. Text$,">")
  825.         
  826.  Pos>0 
  827. [&           subPtr=
  828. Text$,Pos+1))
  829. \"           Text$=
  830. Text$,Pos-1)
  831.         
  832.            subPtr=-1
  833.         
  834.         Pos=
  835. Text$,"}")
  836.         
  837.  Pos>0 
  838. bF           subPtr=
  839. Text$,Pos+1)) : Text$=
  840. Text$,Pos-1):Flag+=&08
  841.         
  842. d7        
  843. Text$,1)="#" 
  844.  Text$=
  845. Text$) : Flag+=&02
  846. e7        Ptr!0=Flag : Ptr!4=subPtr : Ptr!8=&07000021
  847.         
  848. Text$,1)="$" 
  849. g8           !Ptr+=&04 : Ptr!8+=&100 : Pos=
  850. Text$,"(")
  851.            
  852.  Pos>0 
  853. i;              L%=
  854. Text$,Pos+1)) : Text$=
  855. Text$,Pos-1)
  856.            
  857.               L%=12
  858.            
  859. m:           Ptr!12=
  860. Text$,2)) : Ptr!16=-1 : Ptr!20=L%
  861.            Text$=
  862. L%," ")
  863.         
  864.            $(Ptr+12)=Text$
  865. qD           
  866.  Text$-(subPtr>0)>maxx% 
  867.  maxx%=
  868.  Text$-(subPtr>0)
  869.         
  870.         Ptr+=24
  871. t        
  872.  Error control
  873. Error
  874.  "Wimp_DragBox",,-1
  875. z=    !Block=
  876.  : $(Block+4)=
  877. $+"("+
  878. )+") at line "+
  879. {-    
  880.  "Wimp_ReportError",Block,1,"Frank"
  881.  Mouse control
  882. ButtonClick(Block)
  883. ;    Handle%=Block!12 : Icon%=Block!16 : Button%=Block!8
  884.  Handle% 
  885. "        
  886.  -2 : 
  887. MouseOnIconbar
  888. "        
  889.  Main% : 
  890. MouseOnMain
  891. $        
  892.  Prefs% : 
  893. MouseOnPrefs
  894. 9        
  895.  Message%:
  896.  Icon%=2 
  897. CloseWindow(Message%)
  898. $        
  899.  Vocab% : 
  900. MouseOnVocab
  901. (        
  902.  Correct% : 
  903. MouseOnCorrect
  904. $        
  905.  Links% : 
  906. MouseOnLinks
  907. (        
  908.  AddLink% : 
  909. MouseOnAddLink
  910. "        
  911.  Save% : 
  912. MouseOnSave
  913.         
  914. MouseOnSave
  915. 9    
  916.  (Icon%=3 
  917.  Icon%=2) 
  918.  (Button%=1 
  919.  Button%=4) 
  920.        
  921. DragBox
  922.         
  923. ;       
  924.  Icon%=1 
  925.  (Button%=1 
  926.  Button%=4) 
  927. QuickSave
  928.         
  929. DragBox
  930.     Block!0=Save%
  931. '    
  932.  "Wimp_GetWindowState",,Block
  933.     ox%=Block!4-Block!20-2
  934.     oy%=Block!16-Block!24+2
  935.     Block!4=3
  936. %    
  937.  "Wimp_GetIconState",,Block
  938.  DragASprite 
  939.        Block!0=Save%
  940.        Block!4=5
  941.        Block!8+=ox%
  942.        Block!12+=oy%
  943.        Block!16+=ox%
  944.        Block!20+=oy%
  945.        Block!24=0
  946.        Block!28=0
  947.        Block!32=&7FFFFFFF
  948.        Block!36=&7FFFFFFF
  949. #       
  950.  "Wimp_DragBox",,Block
  951.         
  952.        Block!0=Block!8+ox%
  953.        Block!4=Block!12+oy%
  954.        Block!8=Block!16+ox%
  955.         Block!12=Block!20+oy%
  956. >       
  957.  "DragASprite_Start",%11000101,1,"file_1a1",Block
  958.         
  959. MouseOnAddLink
  960. !    
  961.  Button%=1 
  962.  Button%=4 
  963.         
  964.  Icon% 
  965. *            
  966. CloseWindow(AddLink%)
  967. &            
  968.  LinkingWord=-2 
  969. 2                        
  970. CloseWindow(AddLink%)
  971.                    
  972. @                        
  973. AddLink(ShowingLinksOf,LinkingWord)
  974. 2                        
  975. CloseWindow(AddLink%)
  976. 6                        
  977. ShowLinks(ShowingLinksOf)
  978.                    
  979. ?            
  980. ReInitIcon(AddLink%,3,"<End of sentence>")
  981. &                    LinkingWord=-1
  982.         
  983.         
  984. MouseOnCorrect
  985. !    
  986.  Button%=1 
  987.  Button%=4 
  988.         
  989.  Icon% 
  990. *            
  991. CloseWindow(Correct%)
  992.             
  993. ChangeWord
  994.         
  995.         
  996. MouseOnVocab
  997. !    
  998.  Button%=1 
  999.  Button%=4 
  1000.         
  1001.  Icon% 
  1002. !            
  1003.  24:VocabState=1
  1004. !            
  1005.  25:VocabState=2
  1006. !            
  1007.  26:VocabState=3
  1008. !            
  1009.  27:VocabState=4
  1010. 0            
  1011.  10,11,12,13,14,15,16,17,18,19:
  1012. [                
  1013.  (Icon%-10+VocabOffSet)>=0 
  1014.  (Icon%-10+VocabOffSet)<=CurrentTopWords 
  1015. 4                    
  1016.  (Icon%-10+VocabOffSet)>0 
  1017. O                        
  1018. ReInitIcon(AddLink%,3,Word$(Icon%-10+VocabOffSet))
  1019. <                        LinkingWord=Icon%-10+VocabOffSet
  1020.                     
  1021. '                    
  1022.  VocabState 
  1023. K                        
  1024. Correct(Icon%-10+VocabOffSet):VocabState=0
  1025. N                        
  1026. DeleteWord(Icon%-10+VocabOffSet):VocabState=0
  1027. M                        
  1028. ShowLinks(Icon%-10+VocabOffSet):VocabState=0
  1029. L                        
  1030. SwapCaps(Icon%-10+VocabOffSet):VocabState=0
  1031.                     
  1032.                 
  1033. "            
  1034.  Button%=4 
  1035. I                        
  1036.  VocabOffSet>0 
  1037.  VocabOffSet-=1:
  1038. UpdateVocab
  1039.                     
  1040. -                        
  1041.  VocabOffSet>0 
  1042. /                            VocabOffSet-=10
  1043. ?                            
  1044.  VocabOffSet<0 
  1045.  VocabOffSet=0
  1046.                         
  1047. (                        
  1048. UpdateVocab
  1049.                     
  1050. "            
  1051.  Button%=4 
  1052. Y                        
  1053.  VocabOffSet+9<CurrentTopWords 
  1054.  VocabOffSet+=1:
  1055. UpdateVocab
  1056.                     
  1057. =                        
  1058.  VocabOffSet+9<CurrentTopWords 
  1059. /                            VocabOffSet+=10
  1060. A                            
  1061.  VocabOffSet+9>CurrentTopWords 
  1062. ?                                VocabOffSet=CurrentTopWords
  1063. !                            
  1064.                         
  1065. (                        
  1066. UpdateVocab
  1067.                     
  1068.         
  1069.         
  1070. DeleteWord(WNo)
  1071.  WNo<CurrentTopWords 
  1072. *        
  1073.  Swap=WNo 
  1074.  CurrentTopWords-1
  1075. )            Word$(Swap)=Word$(Swap+1)
  1076. /            WordData?Swap=WordData?(Swap+1)
  1077. (            LoPtr=
  1078. BasePointer(Swap)
  1079. *            HiPtr=
  1080. BasePointer(Swap+1)
  1081. '            Links!LoPtr=Links!HiPtr
  1082. /            Links!(LoPtr+4)=Links!(HiPtr+4)
  1083. &            
  1084.  Copy=1 
  1085.  Links!HiPtr
  1086. %                HiPtr+=8:LoPtr+=8
  1087. +                Links!LoPtr=Links!HiPtr
  1088. 3                Links!(LoPtr+4)=Links!(HiPtr+4)
  1089.             
  1090.  Copy
  1091.         
  1092.  Swap
  1093.         
  1094.     CurrentTopWords-=1
  1095. #    
  1096.  Check=0 
  1097.  CurrentTopWords
  1098. $        MPtr=
  1099. BasePointer(Check)
  1100.         MPtr+=12
  1101. -        
  1102.  CheckInside=1 
  1103.  Links!(MPtr-12)
  1104. @            
  1105.  Links!MPtr=WNo 
  1106. BreakLink(CheckInside,Check)
  1107. <            
  1108.  Links!MPtr>WNo 
  1109.  Links!MPtr=(Links!MPtr)-1
  1110.         
  1111.  CheckInside
  1112.  Check
  1113. UpdateVocab
  1114. -    
  1115. UpdateLinks(ShowingLinksOf,LinkList)
  1116.                 
  1117. MouseOnLinks
  1118. !    
  1119.  Button%=1 
  1120.  Button%=4 
  1121.         
  1122.  Icon% 
  1123. V            
  1124. ReInitIcon(AddLink%,3,""):
  1125. OpenWindow(AddLink%,
  1126. ):LinkingWord=-2
  1127.              
  1128.  22:LinkState=1
  1129.              
  1130.  29:LinkState=2
  1131.              
  1132.  30:LinkState=3
  1133. >            
  1134.  0,1,2,3,4,5,6:
  1135. CheckLinkIcon(Icon%+LinkList)
  1136. D            
  1137.  7,8,9,10,11,12,13:
  1138. CheckLinkIcon(Icon%-7+LinkList)
  1139. H            
  1140.  14,15,16,17,18,19,20:
  1141. CheckLinkIcon(Icon%-14+LinkList)
  1142.  "            
  1143.  Button%=4 
  1144. !6                        
  1145.  LinkList>1 
  1146.  LinkList-=1
  1147.                     
  1148. #'                        LinkList-=7
  1149. $5                        
  1150.  LinkList<1 
  1151.  LinkList=1
  1152.                     
  1153. &=                    
  1154. UpdateLinks(ShowingLinksOf,LinkList)
  1155. '5            
  1156.  28:Ptr=
  1157. BasePointer(ShowingLinksOf)
  1158. (%                    Max=Links!Ptr
  1159. )%                    
  1160.  Button%=4 
  1161. *<                        
  1162.  LinkList<(Max-6) 
  1163.  LinkList+=1
  1164.                     
  1165. ,'                        LinkList+=7
  1166. -9                        
  1167.  LinkList>Max 
  1168.  LinkList=Max
  1169.                     
  1170. /=                    
  1171. UpdateLinks(ShowingLinksOf,LinkList)
  1172.         
  1173. 1        
  1174. CheckLinkIcon(Ic)
  1175. 5(    Ptr=
  1176. BasePointer(ShowingLinksOf)
  1177.  Ic<=Links!Ptr 
  1178.         
  1179.  LinkState 
  1180. 8X            
  1181. BreakLink(Ic,ShowingLinksOf):LinkState=0:
  1182. ShowLinks(ShowingLinksOf)
  1183. 9,            
  1184.  2:Rea=Links!(Ptr+(8*Ic)+4)
  1185. :"                    
  1186.  Rea>-1 
  1187. ;7                        
  1188. ShowLinks(Rea):LinkState=0
  1189.                     
  1190. =3            
  1191.  3:ToRemove=(Links!(Ptr+(8*Ic)))-1
  1192. >,                    Links!(Ptr+(8*Ic))=1
  1193. ?/                    Links!(Ptr+4)-=ToRemove
  1194. @2                    
  1195. ShowLinks(ShowingLinksOf)
  1196.         
  1197. B        
  1198. BreakLink(No,From)
  1199.     Ptr=
  1200. BasePointer(From)
  1201. G#    ToRemove=Links!(Ptr+(8*No))
  1202.  No<Links!Ptr 
  1203. I%        
  1204.  Swap=No 
  1205.  (Links!Ptr)-1
  1206. J9            Links!(Ptr+(8*No))=Links!((Ptr+(8*No))+8)
  1207. K>            Links!((Ptr+(8*No))+4)=Links!((Ptr+(8*No))+12)
  1208.         
  1209.  Swap
  1210. M        
  1211.     Links!Ptr-=1
  1212. O#    Links!(Ptr+4)-=ToRemove    
  1213.  Links!Ptr=0 
  1214.         Links!Ptr=1
  1215.         Links!(Ptr+4)=1
  1216.         Links!(Ptr+8)=1
  1217.         Links!(Ptr+12)=-1
  1218. U        
  1219. ShowLinks(WNo)
  1220. CloseWindow(AddLink%)
  1221. Z%    
  1222. ReInitIcon(Links%,33,
  1223. (WNo))
  1224. [)    
  1225. ReInitIcon(Links%,31,Word$(WNo))
  1226.     LinkList=1
  1227. ]"    
  1228. UpdateLinks(WNo,LinkList)
  1229. OpenWindow(Links%,
  1230. UpdateLinks(WNo,LinkList)
  1231.     Ptr=
  1232. BasePointer(WNo)
  1233. c+    
  1234. ReInitIcon(Links%,36,
  1235. (Links!Ptr))
  1236. d/    
  1237. ReInitIcon(Links%,34,
  1238. (Links!(Ptr+4)))
  1239.     ShowingLinksOf=WNo
  1240.     HiLinks=Links!Ptr
  1241. g(    
  1242.  GetLinks=LinkList 
  1243.  LinkList+6
  1244. h!        
  1245.  GetLinks<=HiLinks 
  1246. i.            Wor=Links!(Ptr+(8*GetLinks)+4)
  1247.             
  1248.  Wor<>-1 
  1249. k@                
  1250. ReInitIcon(Links%,GetLinks-LinkList,
  1251. (Wor))
  1252. lF                
  1253. ReInitIcon(Links%,GetLinks-LinkList+7,Word$(Wor))
  1254.             
  1255. n<                
  1256. ReInitIcon(Links%,GetLinks-LinkList,"")
  1257. oO                
  1258. ReInitIcon(Links%,GetLinks-LinkList+7,"<End of sentence>")
  1259.             
  1260. qT            
  1261. ReInitIcon(Links%,GetLinks-LinkList+14,
  1262. (Links!(Ptr+(8*GetLinks))))
  1263.         
  1264. s8            
  1265. ReInitIcon(Links%,GetLinks-LinkList,"")
  1266. t:            
  1267. ReInitIcon(Links%,GetLinks-LinkList+7,"")
  1268. uG            
  1269. ReInitIcon(Links%,GetLinks-LinkList+14,"")            
  1270.         
  1271.  GetLinks
  1272. SwapCaps(WNo)
  1273. {:    
  1274.  WordData?WNo=1 
  1275.  WordData?WNo=0 
  1276.  WordData?WNo=1
  1277. UpdateVocab
  1278. Correct(WNo)
  1279. (    
  1280.  WNo>0 
  1281.  WNo<=CurrentTopWords 
  1282.         Correcting=WNo
  1283. .        
  1284. ReInitIcon(Correct%,2,Word$(WNo))
  1285. .        
  1286. ReInitIcon(Correct%,1,Word$(WNo))
  1287. #        
  1288. OpenWindow(Correct%,
  1289.         
  1290. MouseOnPrefs
  1291.     Update=
  1292. !    
  1293.  Button%=1 
  1294.  Button%=4 
  1295.         
  1296.  Icon% 
  1297. E            
  1298.  (MaxWords>CurrentTopWords+1) 
  1299.  (MaxWords>21) 
  1300. 5                        MaxWords-=1:
  1301. WarnWordLink
  1302. >                        
  1303. ReInitIcon(Prefs%,30,
  1304. (MaxWords))
  1305.                     
  1306. *            
  1307.  MaxWords<TopWords 
  1308. 5                        MaxWords+=1:
  1309. WarnWordLink
  1310. >                        
  1311. ReInitIcon(Prefs%,30,
  1312. (MaxWords))
  1313.                     
  1314. $            
  1315.  MaxLinks>11 
  1316. 5                        MaxLinks-=1:
  1317. WarnWordLink
  1318. >                        
  1319. ReInitIcon(Prefs%,34,
  1320. (MaxLinks))
  1321.                     
  1322. *            
  1323.  MaxLinks<TopLinks 
  1324. 5                        MaxLinks+=1:
  1325. WarnWordLink
  1326. >                        
  1327. ReInitIcon(Prefs%,34,
  1328. (MaxLinks))
  1329.                     
  1330. ?            
  1331.  18:Learning=
  1332. :Update=
  1333. :Learning=
  1334.  LearningOff
  1335. (            
  1336.  19:Learning=
  1337. :Update=
  1338. ,            
  1339.  20:IgnoreCommas=
  1340. :Update=
  1341. ,            
  1342.  21:IgnoreCommas=
  1343. :Update=
  1344. '            
  1345.  10:Linkage=
  1346. :Update=
  1347. '            
  1348.  11:Linkage=
  1349. :Update=
  1350. )            
  1351.  13:Frequency=
  1352. :Update=
  1353. )            
  1354.  14:Frequency=
  1355. :Update=
  1356. )            
  1357.  25:SavePrefs=
  1358. :Update=
  1359. )            
  1360.  26:SavePrefs=
  1361. :Update=
  1362. *            
  1363. DefaultPrefs:Update=
  1364. $            
  1365. SavePreferences
  1366.         
  1367.         
  1368.  Update 
  1369. UpdatePrefs
  1370. WarnWordLink
  1371.  Warned 
  1372.         
  1373. UserMessage("Changing the Max. words or links - the new values only come into effect the next time Frank is run.")
  1374.         Warned=
  1375.         
  1376. MouseOnIconbar
  1377. &    
  1378.  Button%=2 
  1379. OpenMenu(Menu%)
  1380. 6    
  1381.  Button%=1 
  1382.  Button%=4 
  1383. OpenWindow(Main%,
  1384. MouseOnMain
  1385. &    
  1386.  Button%=2 
  1387. OpenMenu(Menu%)
  1388. !    
  1389.  Button%=1 
  1390.  Button%=4 
  1391.         
  1392.  Icon% 
  1393. F            
  1394.  2 : VocabOffSet=0:
  1395. UpdateVocab:
  1396. OpenWindow(Vocab%,
  1397. +            
  1398.  3 : 
  1399. OpenWindow(Prefs%,
  1400. *            
  1401.  4 : 
  1402. OpenWindow(Save%,
  1403.         
  1404.         
  1405.  Frank stuff
  1406. ChangeWord
  1407.     DontChange=
  1408. :Close=
  1409. ,    ChangeTo$=$
  1410. ReadIconText(Correct%,1)
  1411. %    
  1412.  ChangeTo$="" 
  1413.  DontChange=
  1414. "    
  1415. FindWord(ChangeTo$)>0 
  1416. M        
  1417. UserMessage("Sorry, that word already exists in the vocabulary")
  1418.         DontChange=
  1419.         Close=
  1420.         
  1421. A    
  1422.  DontChange 
  1423.  Word$(Correcting)=ChangeTo$:
  1424. UpdateVocab
  1425. (    
  1426.  Close 
  1427. CloseWindow(Correct%)
  1428. Decode
  1429.     NewSentence=
  1430.     Inp$=LastSentence$(1)
  1431. &    Inp$=
  1432. ConvertToLowercase(Inp$)
  1433.  DecodePos<=
  1434. (Inp$)
  1435. 4        
  1436.  NewSentence 
  1437.  LastWord=0:NewSentence=
  1438. -        Wor$=
  1439. GetNextWord(Inp$,DecodePos)
  1440. "        WordNo=
  1441. FindWord(Wor$)
  1442.         
  1443.  WordNo=0 
  1444. ,            
  1445.  CurrentTopWords<MaxWords 
  1446. &                CurrentTopWords+=1
  1447. *                WordNo=CurrentTopWords
  1448. *                
  1449. InitWord(WordNo,Wor$)
  1450.             
  1451. R                Message$="Too many words have been added to the vocabulary.  "
  1452. 6                Message$+="Learning is now off.  "
  1453. ]                Message$+="Increase the Max. Words from prefrences, save the vocab, and "
  1454. *                Message$+="reload me."
  1455. *                
  1456. UserMessage(Message$)
  1457. ,                Learning=
  1458. :LearningOff=
  1459.                  
  1460. UpdatePrefs
  1461.             
  1462.         
  1463.         
  1464.  Learning 
  1465. )            
  1466. AddLink(LastWord,WordNo)
  1467. ?            
  1468.  NewSentence 
  1469. AddLink(WordNo,-1)            
  1470.         
  1471.         LastWord=WordNo
  1472.         
  1473. !    
  1474.  Learning 
  1475. UpdateVocab
  1476.     Decoding%=
  1477. :Respond%=
  1478. AddLink(No,LinkTo)
  1479.     Ptr=
  1480. BasePointer(No)
  1481. )    Linked=
  1482. AlreadyLinked(Ptr,LinkTo)
  1483.  Linked=0 
  1484. "        
  1485.  Links!Ptr<MaxLinks 
  1486.             Links!Ptr+=1
  1487.              Links!(Ptr+4)+=1
  1488. -            Links!(Ptr+((Links!Ptr)*8))=1
  1489. 4            Links!(Ptr+((Links!Ptr)*8)+4)=LinkTo
  1490.         
  1491. F            Message$="Too many links have been added to a word.  "
  1492. 2            Message$+="Learning is now off.  "
  1493. Y            Message$+="Increase the Max. Links from prefrences, save the vocab, and "
  1494. &            Message$+="reload me."
  1495. &            
  1496. UserMessage(Message$)
  1497. (            Learning=
  1498. :LearningOff=
  1499.             
  1500. UpdatePrefs
  1501.         
  1502.         
  1503.         Links!(Ptr+4)+=1
  1504. %        Links!(Ptr+(Linked*8))+=1
  1505.             
  1506. AlreadyLinked(Ptr,LinkTo)
  1507.     Res=0
  1508.     Location=Ptr+12
  1509.  Search=1 
  1510.  Links!Ptr
  1511. 0        
  1512.  LinkTo=Links!Location 
  1513.  Res=Search
  1514.         Location+=8
  1515.  Search
  1516. BasePointer(No)
  1517. =No*((MaxLinks*2)+2)*4
  1518. InitWord(No,Word$)
  1519.     Word$(No)=Word$
  1520.     Ptr=
  1521. BasePointer(No)
  1522.     Links!Ptr=0
  1523.     Links!(Ptr+4)=0
  1524.     WordData?No=0
  1525. GetNextWord(Str$,
  1526.  pos)
  1527. !%    ReadyToStop=
  1528. :Stop=
  1529. :Word$=""
  1530.  Stop
  1531. #         Letter$=
  1532. Str$,pos,1)
  1533. $#        AddOk=
  1534. OkToAdd(Letter$)
  1535. %M        NewReadyToStop=(Letter$=" " 
  1536.  Letter$=" " 
  1537. Terminator(Letter$))
  1538. &_        NewSentence=(
  1539. Terminator(Letter$) 
  1540.  (Letter$="," 
  1541.  IgnoreCommas))) 
  1542.  NewSentence
  1543. '9        
  1544.  AddOk 
  1545.  ReadyToStop 
  1546.  pos-=1:Stop=
  1547. :AddOk=
  1548. (&        ReadyToStop=NewReadyToStop
  1549. )$        
  1550.  AddOk 
  1551.  Word$+=Letter$
  1552.         pos+=1
  1553. +0        
  1554.  pos>
  1555. (Str$) 
  1556.  Stop=
  1557. :NewSentence=
  1558. ,        
  1559. =Word$
  1560.         
  1561. OkToAdd(Let$)
  1562.     Res=
  1563.  Let$ 
  1564. 2+        
  1565.  ",","."," ","!","?"," ":Res=
  1566. 3        
  1567. 4     
  1568. Ignore$,Let$) 
  1569.  Res=
  1570. Terminator(Let$)
  1571.     Res=
  1572.  Let$ 
  1573.         
  1574.  ".","!","?":Res=
  1575. ;        
  1576. FindWord(Word$)
  1577.     Res=0
  1578.  CurrentTopWords>0 
  1579. A(        
  1580.  Search=1 
  1581.  CurrentTopWords
  1582. B2            
  1583.  Word$=Word$(Search) 
  1584.  Res=Search
  1585.         
  1586.  Search
  1587. D        
  1588. ConvertToLowercase(Inp$)
  1589.  convert=1 
  1590. (Inp$)
  1591. I$        Letter$=
  1592. Inp$,convert,1)
  1593. J/        
  1594. (Letter$)>=65 
  1595. (Letter$)<=90 
  1596. K(            Letter$=
  1597. (Letter$)+32)
  1598. L(            
  1599. Inp$,convert,1)=Letter$
  1600.         
  1601.  convert
  1602. O    =Inp$
  1603. Respond
  1604.     TPtr=
  1605. BasePointer(0)
  1606. S+    
  1607.  CurrentTopWords=0 
  1608.  Links!Ptr=0 
  1609. TG        Sentence$="Sorry, I'm too stupid to respond at the moment!"
  1610. U        
  1611.         Sentence$=""
  1612.         LastWord=0
  1613.         
  1614.  Linkage 
  1615.             Finished=
  1616.             
  1617.  Finished
  1618. [+                Word=
  1619. GetWord(LastWord)
  1620. \                 
  1621.  Word<=-1 
  1622. ]"                    Finished=
  1623.                 
  1624. _-                    NextWord$=Word$(Word)
  1625. `8                    
  1626.  WordData?Word=1 
  1627.  LastWord=0 
  1628. aC                        
  1629. NextWord$,1)=
  1630. UpperCase(
  1631. NextWord$,1))
  1632.                     
  1633. c6                    
  1634.  LastWord<>0 
  1635.  Sentence$+=" "
  1636. d,                    Sentence$+=NextWord$
  1637.                 
  1638. f!                LastWord=Word
  1639.             
  1640.         
  1641. i"            
  1642.  AddWord=1 
  1643. j+                Word=
  1644. (CurrentTopWords)
  1645. k)                NextWord$=Word$(Word)
  1646. l4                
  1647.  WordData?Word=1 
  1648.  LastWord=0 
  1649. m?                    
  1650. NextWord$,1)=
  1651. UpperCase(
  1652. NextWord$,1))
  1653.                 
  1654. o?                
  1655.  LastWord<>0 
  1656.  Sentence$+=" " 
  1657.  LastWord=1
  1658. p(                Sentence$+=NextWord$
  1659.             
  1660.  AddWord
  1661.         
  1662. s%        Sentence$+=
  1663. AddTerminator
  1664. t        
  1665. MoveSentences
  1666. v"    LastSentence$(1)=Sentence$
  1667.     LastWho(1)=2
  1668. UpdateLastSent
  1669.     Respond%=
  1670. :Decoding%=
  1671.     Waiting%=
  1672. UpperCase(Letter$)
  1673. ~*    
  1674. (Letter$)>97 
  1675. (Letter$)<122 
  1676. $        Letter$=
  1677. (Letter$)-32)
  1678.         
  1679. =Letter$
  1680. AddTerminator
  1681.     Term=
  1682.  Term 
  1683.         
  1684.  1:Res$="."
  1685.         
  1686.  2:Res$="?"
  1687.         
  1688.  3:Res$="!"
  1689.         
  1690.  4:Res$="..."
  1691.         
  1692.     =Res$
  1693. GetWord(No)
  1694.  WordNo
  1695.     Ptr=
  1696. BasePointer(No)
  1697.     NoOfLinks=Links!Ptr
  1698.     Called=Links!(Ptr+4)
  1699.  NoOfLinks=1 
  1700.         WordNo=1
  1701.         
  1702.         
  1703.  Frequency 
  1704. #            ConnectNo=
  1705. (Called)
  1706. '            WordNo=-2:CurrentlyOn=0
  1707. '            
  1708.  GetWord=1 
  1709.  NoOfLinks
  1710. 8                CurrentlyOn+=Links!(Ptr+(GetWord*8))
  1711. >                
  1712.  (CurrentlyOn>=ConnectNo) 
  1713.  (WordNo=-2) 
  1714. 8                    WordNo=GetWord:GetWord=NoOfLinks
  1715.                 
  1716.             
  1717.  GetWord
  1718.             
  1719.  WordNo=-2 
  1720. i                
  1721. UserMessage("Umm...  Somehow I've managed to go over the limit... Ending sentence.")
  1722.             
  1723.         
  1724. #            WordNo=
  1725. (NoOfLinks)
  1726.         
  1727.         
  1728. :    
  1729.  WordNo>0 
  1730.  Res=Links!(Ptr+(WordNo*8)+4) 
  1731.  Res=-1
  1732.  Disc IO
  1733. LoadFile(Block%)
  1734. (    
  1735.  Block%!40>0 
  1736.  Block%!40<4096 
  1737.        
  1738.  Block%!40<>&1A1 
  1739.           
  1740.  Block%!16=3 
  1741. h             
  1742. UserMessage("What!!!!   Are you joking? I can't load that! I need a vocabulary file!")
  1743.           
  1744.        
  1745. 2          CurrentFile$=
  1746. GetFilename(Block%+44)
  1747. /          
  1748. ReInitIcon(Save%,0,CurrentFile$)
  1749.           
  1750.        
  1751.         
  1752. .     Block!12=Block!8:Block!16=3:!Block=64
  1753. /     
  1754.  "Wimp_SendMessage",17,Block,Block!4
  1755. 7     CurrentFile$=
  1756. GetLeaf($
  1757. ReadIconText(Save%,0))
  1758. '     outfile$=
  1759. ZeroString(Block+44)
  1760. +     CurrentFile$=outfile$+CurrentFile$
  1761. *     
  1762. ReInitIcon(Save%,0,CurrentFile$)
  1763.      
  1764. SaveFile
  1765. QuickSave
  1766.      
  1767. CurrentFile$,".")=0 
  1768.         
  1769.  "Wimp_DragBox",,-1
  1770. l       !Block=
  1771.  : $(Block+4)="You need to drag the icon to a directory window to save the vocabulary"+
  1772. 0       
  1773.  "Wimp_ReportError",Block,1,"Frank"
  1774.         
  1775. /       CurrentFile$=$
  1776. ReadIconText(Save%,0)
  1777.        
  1778. SaveFile
  1779.         
  1780. SaveFile
  1781.     File%=
  1782. (CurrentFile$)
  1783.  #File%,Version
  1784.  SavePrefs=
  1785.         
  1786.  #File%,1
  1787. 2        
  1788.  #File%,Learning,IgnoreCommas,Linkage
  1789. :        
  1790.  #File%,Frequency,SavePrefs,AutoLoad$,Ignore$
  1791.         
  1792.         
  1793.  #File%,0
  1794.         
  1795.      
  1796.  #File%,CurrentTopWords
  1797. !    
  1798.  Sav=0 
  1799.  CurrentTopWords
  1800.         
  1801.  #File%,Word$(Sav)
  1802. !        
  1803.  #File%,WordData?Sav
  1804. !        Ptr=
  1805. BasePointer(Sav)
  1806. $        
  1807.  LinkData=0 
  1808.  Links!Ptr
  1809. 0            
  1810.  #File%,Links!Ptr,Links!(Ptr+4)
  1811.             Ptr+=8
  1812.         
  1813.  LinkData
  1814.  #File%
  1815. )    
  1816.  "OS_File",18,CurrentFile$,&1A1
  1817. CloseWindow(Save%)
  1818.     File%=
  1819. (CurrentFile$)
  1820.  #File%,LoadingVersion
  1821.     PrefsSaved=
  1822.  #File%
  1823.  PrefsSaved=1 
  1824. 2        
  1825.  #File%,Learning,IgnoreCommas,Linkage
  1826. :        
  1827.  #File%,Frequency,SavePrefs,AutoLoad$,Ignore$
  1828.         
  1829. UpdatePrefs
  1830.         
  1831.  #File%,SavedWords
  1832. %    TooManyWords=0:TooManyLinks=0
  1833.  SavedWords>MaxWords 
  1834. ,        TooManyWords=SavedWords-MaxWords
  1835.         SavedWords=MaxWords
  1836.         
  1837. "    CurrentTopWords=SavedWords
  1838.  Loa=0 
  1839.  SavedWords
  1840.         
  1841.  #File%,Word$(Loa)
  1842. !        WordData?Loa=
  1843.  #File%
  1844. !        Ptr=
  1845. BasePointer(Loa)
  1846. ,        
  1847.  #File%,Links!Ptr,Links!(Ptr+4)
  1848.         OrPtr=Ptr
  1849. "        
  1850.  Links!Ptr>MaxLinks 
  1851. 7            
  1852.  TooManyLinks<((Links!Ptr)-MaxLinks) 
  1853. 5                TooManyLinks=(Links!Ptr)-MaxLinks
  1854.             
  1855.         
  1856. $        
  1857.  LinkData=1 
  1858.  Links!Ptr
  1859.             Ptr+=8
  1860. &            
  1861.  LinkData<=MaxLinks 
  1862. 4                
  1863.  #File%,Links!Ptr,Links!(Ptr+4)
  1864.             
  1865. (                
  1866.  #File%,Dumpa,Dumpb
  1867. "                Links!OrPtr-=1
  1868. *                Links!(OrPtr+4)-=Dumpa
  1869.             
  1870.         
  1871.  LinkData
  1872.  #File%
  1873.     Mess$=""
  1874. +    
  1875.  TooManyWords>0 
  1876.  TooManyLinks=0 
  1877. R        Mess$="Not all of the vocabulary was loaded, because the current word"
  1878. =        Mess$+=" limit is "+
  1879. (TooManyWords)+" too small."
  1880.         
  1881. +    
  1882.  TooManyWords=0 
  1883.  TooManyLinks>0 
  1884. O        Mess$="At least one of the words does not have all it's link data,"
  1885. V        Mess$+=" because the current link limit is "+
  1886. (TooManylinks)+" too small."
  1887.         
  1888. +    
  1889.  TooManyWords>0 
  1890.  TooManyLinks>0 
  1891. R        Mess$="Not all of the vocabulary was loaded, because the current word"
  1892. A        Mess$+=" limit is "+
  1893. (TooManyWords)+" too small, and"
  1894. P        Mess$=" at least one of the words does not have all it's link data,"
  1895. V        Mess$+=" because the current link limit is "+
  1896. (TooManylinks)+" too small."
  1897.         
  1898. |    
  1899.  Mess$<>"" 
  1900. UserMessage(Mess$+"  This may make Frank VERY unstable.  I suggest you alter the prefs, and reload.")
  1901. UpdateVocab
  1902.